/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-11-02
 * Time:22:58
 */

import java.util.ArrayList;
import java.util.List;

/**
 * 力扣94:二叉树的中序遍历
 */

public class inorderTraversal {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        inorder(root, res);
        return res;
    }

    public void inorder(TreeNode root, List<Integer> res) {
        if (root == null) {
            return;
        }
        inorder(root.left, res);
        res.add(root.val);
        inorder(root.right, res);
    }
}
